package com.shu.qq.data.bean

import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody

class BaseRequest private constructor(){
    val data = mutableMapOf<String,String>()
    companion object{
        private  val MEDIA_TYPE: MediaType? = "application/json; charset=UTF-8".toMediaTypeOrNull()
        fun Builder():BaseRequest{
            return BaseRequest()
        }
    }
    fun put(key:String,value:String) :BaseRequest{
        data[key] = value
        return this
    }
    fun build() :RequestBody{
        val json = Gson().toJson(data)
        return  json.toRequestBody(MEDIA_TYPE)
    }
}